/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Entität zur Abbildung des Tipps des Tages.
 * Hat eine n zu 1 Beziehung zur Userloginaccount Entität.
 * Todo: 
 * Für jedes Datum darf nur ein Datensatz vorhanden Sein.
 * @tdtauthor Alex
 */
@Entity
@Table(name = "TIPPDESTAGES")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tippdestages.findAll", query = "SELECT t FROM Tippdestages t"),
    @NamedQuery(name = "Tippdestages.findByTdtid", query = "SELECT t FROM Tippdestages t WHERE t.tdtid = :tdtid"),
    @NamedQuery(name = "Tippdestages.findByTdtauthor", query = "SELECT t FROM Tippdestages t WHERE t.tdtauthor = :tdtauthor"),
    @NamedQuery(name = "Tippdestages.findByTdtname", query = "SELECT t FROM Tippdestages t WHERE t.tdtname = :tdtname"),
    @NamedQuery(name = "Tippdestages.findByTdt", query = "SELECT t FROM Tippdestages t WHERE t.tdt = :tdt")})
public class Tippdestages implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "TDTID")
    private Integer tdtid;
//    @Basic(optional = false)
//    @NotNull
//    @Column(name = "TDTAUTHOR")
//    private int tdtauthor;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2048)
    @Column(name = "TDTNAME")
    private String tdtname;
    @Basic(optional = false)
    @NotNull
    @Lob
    @Size(min = 1, max = 32700)
    @Column(name = "TDTCONTENT")
    private String tdtcontent;
    @Basic(optional = false)
    @NotNull
    @Column(name = "TDT")
    @Temporal(TemporalType.DATE)
    private Date tdt;
    
    @ManyToOne
    @JoinColumn(name="TDTAUTHOR",referencedColumnName="LOGINID")
    protected Userloginaccount tdtauthor;

    public Userloginaccount getAuthor() {
        return tdtauthor;
    }

    public void setAuthor(Userloginaccount author) {
        this.tdtauthor = author;
    }

    public Tippdestages() {
    }

    public Tippdestages(Integer tdtid) {
        this.tdtid = tdtid;
    }

    public Tippdestages(Integer tdtid, Userloginaccount tdtauthor, String tdtname, String tdtcontent, Date tdt) {
        this.tdtid = tdtid;
        this.tdtauthor = tdtauthor;
        this.tdtname = tdtname;
        this.tdtcontent = tdtcontent;
        this.tdt = tdt;
    }

    public Integer getTdtid() {
        return tdtid;
    }

    public void setTdtid(Integer tdtid) {
        this.tdtid = tdtid;
    }

    public String getTdtname() {
        return tdtname;
    }

    public void setTdtname(String tdtname) {
        this.tdtname = tdtname;
    }

    public String getTdtcontent() {
        return tdtcontent;
    }

    public void setTdtcontent(String tdtcontent) {
        this.tdtcontent = tdtcontent;
    }

    public Date getTdt() {
        return tdt;
    }

    public void setTdt(Date tdt) {
        this.tdt = tdt;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tdtid != null ? tdtid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tippdestages)) {
            return false;
        }
        Tippdestages other = (Tippdestages) object;
        if ((this.tdtid == null && other.tdtid != null) || (this.tdtid != null && !this.tdtid.equals(other.tdtid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getTdtid() + " " + getTdtname();
    }
    
}
